import request from "@/utils/request";

//获取
export function getOrders(page, size, search, userId, status) {
    return request({
        method: "get",
        url: '/orders/getOrders',
        params: {
            page: page,
            size: size,
            search: search,
            userId: userId,
            status: status
        }
    })
}

//下单
export function createOrder(params = {}) {
    return request({
        method: "post",
        url: '/orders/createOrder',
        params
    })
}

//更新
export function updateOrder(orderId, paymentType, userId, status) {
    return request({
        method: "post",
        url: '/orders/updateOrder',
        params: {
            orderId: orderId,
            paymentType: paymentType,
            userId: userId,
            status: status
        }
    })
}

//发货
export function shipmentsOrder(order = {}) {
    return request({
        method: "post",
        url: '/orders/shipmentsOrder',
        params: order
    })
}

//删除订单
export function deleteOrder(orderId, userId) {
    return request({
        method: "delete",
        url: '/orders/deleteOrder',
        params: {
            orderId: orderId,
            userId: userId
        }
    })
}

export default {
    updateOrder, getOrders, shipmentsOrder, createOrder, deleteOrder
}
